/*
 	找回密码
 * */
define(['../../common/service'], function( http) {
    (function bindLoginEvent() {
        var myForm = $("#forgetPwdForm");
        //配置I18N
        var sl = window.localStorage.getItem('language') || 'zh-cn';
        I18N.setLanguage(sl);
        // 绑定提交事件
        var submitForm = myForm.find('.submitForm');
        submitForm.unbind('click');
        submitForm.click(function () {
            var email = myForm.find("#email").val().trim();
            if ('' == email) {
                Kit.alert_info(I18N.getText('user','enteremail'));
                myForm.find("#email").focus();
                return false;
            } else {
                var strRegex = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
                var reg = new RegExp(strRegex);
                if (!reg.test(email)) {
                	Kit.alert_info(I18N.getText('user','emailTypeError'));
                    return false;
                }
            }
            var param = {
                email: email
            };
            var loadingArea = $('#forgetPwdForm');
            Kit.loading.show(loadingArea);
            http.work('/login/doforget',param,'POST').then(function(res){
            	if(res.flag == 'success'){
            		var data = res.data;
                    window.location.href = "login.html";
                }else{
                	Kit.alert2(res.msg || I18N.getText('user','forgetpwdFail'))
                }
                Kit.loading.hide(loadingArea);
            });
        });
    })()
})
